<template>
	<view>
		<view class="content" v-if="list.length" >
			<view class="list_box" v-for="(item,index) in list" :key="index">
				<view class="flex align-center justify-between">
					<view></view>
					<view class="data">{{item.createTime}}</view>
				</view>
				<view class="name flex align-center" @click="copyClick(item.title)" v-if="item.type==1">{{item.title}}
				<image src="../../../../static/image/copy.png" style="width: 30upx;height: 30upx;"></image>
				</view>
				<view class="name" v-else>{{item.title}}</view>
				<view>{{item.content}}</view>
				<!-- <view class="list_left">
					<view class="flex align-center justify-between">
						<view class="name">{{item.title}}</view>
						<view class="data">{{item.createTime}}</view>
					</view>
					<view>{{item.content}}</view>
				</view>
				<view class="list_right" style="color: red;" v-if="item.type==2">- {{item.money}}</view>
				<view class="list_right" style="color: #33D442;" v-if="item.type==1">+ {{item.money}}</view> -->
			</view>
		</view>
		<empty v-else></empty>
	</view>
</template>

<script>
	import empty from '@/components/empty'
	export default {
		components: {
			empty
		},
		data() {
			return {
				list: [],
				page: 1,
				totalCount: 0
			}
		},
		onLoad() {
			this.taskData()
		},
		methods: {
			copyClick(copy) {
				uni.setClipboardData({
					data: copy,
					success: function(res) {
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: "复制成功",
									icon: 'none',
								});
							},
						});
					},
				});
			},
			// 获取任务数据
			taskData() {
				this.$Request.getT('/app/userinfo/findMoneyDetails?page='+this.page+'&limit=15').then(res => {
					if(res.code==0){
						// this.list = res.data.list
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = this.list.concat(res.data.list)
						}
						
						this.totalCount = res.data.totalPage
					}
					console.log('res',res)
					uni.stopPullDownRefresh();
				});
			},
		},
		// 上拉加载
		onReachBottom: function() {
			if (this.page < this.totalCount) {
				this.page += 1;
				this.taskData();
			} else {
				uni.showToast({
					title: '已经最后一页啦',
					icon: 'none'
				})
			}
			
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.taskData();
		},
	}
</script>

<style>
	body {
		background: #F5F5F5;
	}

	.content {
		width: 100%;
		background: #FFFFFF;
		/* margin-top: 20rpx; */
		padding-bottom: 50rpx;
		padding-top: 20rpx;
	}

	.list_box {
		width: 90%;
		margin: 0 auto;
		/* display: flex; */
		line-height: 45rpx;
		padding-top: 20rpx;
		padding-bottom: 20upx;
		border-bottom: 1rpx solid #f8f8f8;
	}

	.list_left {
		/* flex: 2; */
	}

	.name {
		font-size: 26rpx;
		color: #333333;
		font-weight: bold;
		letter-spacing: 2rpx;
	}

	.data {
		color: #999999;
		font-size: 24rpx;
	}

	.list_right {
		
		display: flex;
		justify-content: flex-end;
		 align-items: center; 
		font-size: 31rpx;
	}
</style>
